Drop characters if an asynchronous serial tx buffer fills up.
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 23 Apr 2008 13:17:35 +0000 (14:17 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 23 Apr 2008 13:17:35 +0000 (14:17 +0100)
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/drivers/char/serial.c

index cf2df9b3df8bb6b95fda6d1e675a0ebe280fd8b1..34c188c6416260029b8afba9db7a94259f20a9f0 100644 (file)
@@ -15,6 +15,9 @@
 #include <xen/mm.h>
 #include <xen/serial.h>
 
+/* Never drop characters, even if the async transmit buffer fills. */
+/* #define SERIAL_NEVER_DROP_CHARS 1 */
+
 unsigned int serial_txbufsz = 16384;
 static void __init parse_serial_tx_buffer(const char *s)
 {
@@ -91,22 +94,24 @@ void serial_tx_interrupt(struct serial_port *port, struct cpu_user_regs *regs)
 
 static void __serial_putc(struct serial_port *port, char c)
 {
-    int i;
-
     if ( (port->txbuf != NULL) && !port->sync )
     {
         /* Interrupt-driven (asynchronous) transmitter. */
+#ifdef SERIAL_NEVER_DROP_CHARS
         if ( (port->txbufp - port->txbufc) == serial_txbufsz )
         {
-            /* Buffer is full: we spin, but could alternatively drop chars. */
+            /* Buffer is full: we spin waiting for space to appear. */
+            int i;
             while ( !port->driver->tx_empty(port) )
                 cpu_relax();
             for ( i = 0; i < port->tx_fifo_size; i++ )
                 port->driver->putc(
                     port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);
             port->txbuf[mask_serial_txbuf_idx(port->txbufp++)] = c;
+            return;
         }
-        else if ( ((port->txbufp - port->txbufc) == 0) &&
+#endif
+        if ( ((port->txbufp - port->txbufc) == 0) &&
                   port->driver->tx_empty(port) )
         {
             /* Buffer and UART FIFO are both empty. */